package com.wjerp.tplus.server.common.exception;

import com.wjerp.tplus.server.common.constant.ErrorDetail;

import java.text.MessageFormat;

/**
 * @author lishuailei
 */
public class UnAuthException extends Exception {
    /**
     *
     */
    private static final Long serialVersionUID = 1L;

    String errorMsg;
    String errorCode;

    public UnAuthException(){
        super();
    }

    public UnAuthException(String errorCode, String errorMsg){
        super();

        this.errorCode = errorCode;
        this.errorMsg = errorMsg;

    }

    public UnAuthException(ErrorDetail e){
        super();

        this.errorCode = e.getErrorCode();
        this.errorMsg = e.getErrorMsg();
    }

    public UnAuthException(ErrorDetail e, String[] params){
        super();
        this.errorCode = e.getErrorCode();
        String errorMsg = e.getErrorMsg();
        this.errorMsg = MessageFormat.format(errorMsg, params);
    }

    public String getErrorMsg(){
        return errorMsg;
    }

    public String getErrorCode(){
        return errorCode;
    }

}
